package com.sun.java.network;


import java.io.*;
import java.net.*;


public class Server extends Thread{

	private Socket client;
	
	public Server(Socket client){
		
		this.client = client;
	}
	public void run(){
		BufferedReader in = null;
		PrintWriter out = null;
		try {
		 in = new BufferedReader(new InputStreamReader(client.getInputStream()));
         out = new PrintWriter(client.getOutputStream(), true);
			
		} catch (Exception e) {
			// TODO: handle exception
			System.err.println(e.toString());
			System.exit(1);
		}
		circle c = new circle();
        String strIn ;
		try{
            while ((strIn = in.readLine())!= null){
            	c.parse(strIn);           	
            	out.println("echo: "+"Lon: "+c.getLon()+" Lat: "+c.getLat()+"Radius: "+c.getRadius());
            }
		    out.close();
		    in.close();
			client.close();
		}catch(Exception e){
			System.err.println(e.toString());
		}
		
	}
	
	public static void main(String[] args)throws IOException{
		
		ServerSocket myserver = new ServerSocket(8890);
		while(true){

			Server client = new Server(myserver.accept());
			client.start();
			
		}
		
	}

}
